﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
    <title>Turnstile: Turnstile.cs Source File</title>
    <link href="/Content/Help.css" rel="stylesheet" type="text/css" />
    <link href="/Content/css/tabs.css" rel="stylesheet" type="text/css" />
    <link href="/Content/css/doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="header">
        <img id="logo" alt="StateForge" src="/Content/Images/StateForgeLogo.png" />
        <div id="title">
            <h1>
                C# examples using state machines generated by StateBuilderDotNet
            </h1>
            <h3>
                Turnstile: Turnstile.cs Source File
            </h3>
        </div>
        <div id="menucontainer">
            <ul id="menu">
                <li><a href="/">Home</a></li>
                <li><a href="/Home/Download">Downloads</a></li>
                <li><a href="/Help/state-machine-tools.aspx">Help</a></li>
                <li><a href="/Home/Faq">F.A.Q</a></li>
                <li><a href="/Home/About">Contact us</a></li>
            </ul>
        </div>
    </div>
<!-- Generated by Doxygen 1.7.4 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">Turnstile.cs</div>  </div>
</div>
<div class="contents">
<a href="_turnstile_8cs.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ﻿
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="keyword">namespace </span>StateForge.Examples.Turnstile
<a name="l00004"></a>00004 {
<a name="l00005"></a>00005     <span class="keyword">using</span> System;
<a name="l00006"></a>00006 
<a name="l00007"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_barrier.html">00007</a>     <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_barrier.html">Barrier</a>
<a name="l00008"></a>00008     {
<a name="l00009"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_barrier.html#a1fc292bd1c6f10e859089020e5a39e4e">00009</a>         <span class="keyword">public</span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> DoLock()
<a name="l00010"></a>00010         {
<a name="l00011"></a>00011             Console.WriteLine(<span class="stringliteral">&quot;Barrier.DoLock&quot;</span>);
<a name="l00012"></a>00012         }
<a name="l00013"></a>00013 
<a name="l00014"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_barrier.html#a87b58d24f68261e56dbf6d24fb8d5ac3">00014</a>         <span class="keyword">public</span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> DoUnlock()
<a name="l00015"></a>00015         {
<a name="l00016"></a>00016             Console.WriteLine(<span class="stringliteral">&quot;Barrier.DoUnlock&quot;</span>);
<a name="l00017"></a>00017         }
<a name="l00018"></a>00018     }
<a name="l00019"></a>00019 
<a name="l00020"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_alarm.html">00020</a>     <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_alarm.html">Alarm</a>
<a name="l00021"></a>00021     {
<a name="l00022"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_alarm.html#a22eb6c3c21c90ed1063192d170c35de1">00022</a>         <span class="keyword">public</span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> DoRing()
<a name="l00023"></a>00023         {
<a name="l00024"></a>00024             Console.WriteLine(<span class="stringliteral">&quot;Alarm.DoRing&quot;</span>);
<a name="l00025"></a>00025         }
<a name="l00026"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_alarm.html#a83707bd0d4c612de2cf55d605a100721">00026</a>         <span class="keyword">public</span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> DoAlertStaff()
<a name="l00027"></a>00027         {
<a name="l00028"></a>00028             Console.WriteLine(<span class="stringliteral">&quot;Alarm.DoAlertStaff&quot;</span>);
<a name="l00029"></a>00029         }
<a name="l00030"></a>00030     }
<a name="l00031"></a>00031 
<a name="l00032"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_coin_machine.html">00032</a>     <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_coin_machine.html">CoinMachine</a>
<a name="l00033"></a>00033     {
<a name="l00034"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_coin_machine.html#aba84ee9e8860bec345acd29774ef4b8c">00034</a>         <span class="keyword">public</span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> DoAccept()
<a name="l00035"></a>00035         {
<a name="l00036"></a>00036             Console.WriteLine(<span class="stringliteral">&quot;CoinMachine.DoAccept&quot;</span>);
<a name="l00037"></a>00037         }
<a name="l00038"></a>00038 
<a name="l00039"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_coin_machine.html#af4370ea03ff694a2f7cfcdc870a6bf3a">00039</a>         <span class="keyword">public</span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> DoReject()
<a name="l00040"></a>00040         {
<a name="l00041"></a>00041             Console.WriteLine(<span class="stringliteral">&quot;CoinMachine.DoReject&quot;</span>);
<a name="l00042"></a>00042         }
<a name="l00043"></a>00043     }
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html">00045</a>     <span class="keyword">public</span> <span class="keyword">partial class </span><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html">Turnstile</a>
<a name="l00046"></a>00046     {
<a name="l00047"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#a5bddf3a0033dcb6ac2397f30b7dc4f43">00047</a>         <span class="keyword">private</span> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_barrier.html">Barrier</a> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#a5bddf3a0033dcb6ac2397f30b7dc4f43">barrier</a>;
<a name="l00048"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#adba52917c4c255f5dff9772fa2106330">00048</a>         <span class="keyword">private</span> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_alarm.html">Alarm</a> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#adba52917c4c255f5dff9772fa2106330">alarm</a>;
<a name="l00049"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#a0f200da95d391fe1bf143076dbbc13f9">00049</a>         <span class="keyword">private</span> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_coin_machine.html">CoinMachine</a> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#a0f200da95d391fe1bf143076dbbc13f9">coinMachine</a>;
<a name="l00050"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#a6f8d984a0901b76dc88abb51f524bee0">00050</a>         <span class="keyword">private</span> TurnstileContext <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#a6f8d984a0901b76dc88abb51f524bee0">context</a>;
<a name="l00051"></a>00051 
<a name="l00052"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#ae78dc07aa238f2d61eb4e24c18189c27">00052</a>         <span class="keyword">public</span> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html">Turnstile</a>()
<a name="l00053"></a>00053         {
<a name="l00054"></a>00054             this.barrier = <span class="keyword">new</span> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_barrier.html">Barrier</a>();
<a name="l00055"></a>00055             this.alarm = <span class="keyword">new</span> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_alarm.html">Alarm</a>();
<a name="l00056"></a>00056             this.coinMachine = <span class="keyword">new</span> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_coin_machine.html">CoinMachine</a>();
<a name="l00057"></a>00057             this.context = <span class="keyword">new</span> TurnstileContext(barrier, alarm, coinMachine);
<a name="l00058"></a>00058             this.context.EnterInitialState();
<a name="l00059"></a>00059         }
<a name="l00060"></a>00060 
<a name="l00061"></a><a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html#a8b824e7b5c5ce805cbba4ab886aa0371">00061</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> Main(<span class="keywordtype">string</span>[] args)
<a name="l00062"></a>00062         {
<a name="l00063"></a>00063             <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html">Turnstile</a> myTurnstile = <span class="keyword">new</span> <a class="code" href="class_state_forge_1_1_examples_1_1_turnstile_1_1_turnstile.html">Turnstile</a>();
<a name="l00064"></a>00064             myTurnstile.Coin();
<a name="l00065"></a>00065             myTurnstile.Pass();
<a name="l00066"></a>00066             myTurnstile.Coin();
<a name="l00067"></a>00067             myTurnstile.Pass();
<a name="l00068"></a>00068             Environment.Exit(0);
<a name="l00069"></a>00069         }
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071 }
</pre></div></div>
</div>
﻿<div id="footer">
    <hr />
    <p>
        Copyright &copy; 2011 StateForge.</p>
    <hr />
</div>
</body> </html> 
